<script>
    class Promise{
        PromiseState = 'ing'
        PromiseResult = null
        constructor(callback){
            let resolve = (data) => {
                if(this.PromiseState !=='ing') return
                this.PromiseState = 'success'
                this.PromiseResult = data
            }
            let reject = (data) => {
                if(this.PromiseState !=='ing') return
                this.PromiseState = 'error'
                this.PromiseResult = data
            }
            callback(resolve,reject)
        }
    }
    Promise.prototype.then = function(fn1,fn2){
        if (this.PromiseState === 'success'){
            fn1(this.PromiseResult)
        }
        if (this.PromiseState === 'error'){
            fn2(this.PromiseResult)
        }
    }
    Promise.prototype.catch = function(){}
    Promise.prototype.finally = function(){}
    Promise.resolve = function(){}
    Promise.reject = function(){}
    Promise.all = function() {}
Promise.race = function() {}
Promise.allSettled = function() {}
Promise.any = function() {}

const p = new Promise((resolve, reject) => {
    // console.log('我执行啦')
    resolve(11)
    reject(22)
})
// console.log(p)


p.then(
    res => {
        console.log('res', res);
    },
    err => {
        console.log('err', err);
    }
)
</script>